<script setup>
import { defineProps, defineEmits } from 'vue'

const props = defineProps({
  title: {
    type: String,
    required: true
  },
  subtitle: {
    type: String,
    default: ''
  },
  showBack: {
    type: Boolean,
    default: false
  }
})

const emit = defineEmits(['back', 'refresh'])

const handleBack = () => {
  emit('back')
}

const handleRefresh = () => {
  emit('refresh')
}
</script>

<template>
  <div class="page-header">
    <div class="header-left">
      <el-button v-if="showBack" icon="Back" circle @click="handleBack" />
      <div class="header-title">
        <h2>{{ title }}</h2>
        <p v-if="subtitle">{{ subtitle }}</p>
      </div>
    </div>
    <div class="header-right">
      <el-button icon="Refresh" circle @click="handleRefresh" />
      <slot name="actions"></slot>
    </div>
  </div>
</template>

<style scoped>
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #ebeef5;
}

.header-left {
  display: flex;
  align-items: center;
}

.header-title {
  margin-left: 10px;
}

.header-title h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  color: #303133;
}

.header-title p {
  margin: 5px 0 0;
  font-size: 14px;
  color: #909399;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
</style> 